//
//  WeiboStatus.swift
//  weiboSwift1.0
//
//  Created by xuNick on 16/4/20.
//  Copyright © 2016年 NN. All rights reserved.
//

import UIKit

class WeiboStatus: NSObject {
    
    
    
    
    // 而 Int32位的最大值是没有微博id大的，所以会造成溢出
    var id: Int64 = 0

   
    var text:String?
    
    /// 微博的创建时间
    var created_at: String?
    
    //来源
    var source:String?
    
    //用户信息
    var user:UersInfo?
    
    //转发内容
     var retweeted_status: WeiboStatus?
    
    //图片地址
     var pic_urls: [PictureUrls]?
    
    init(dict: [String: AnyObject]) {
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            guard let dict = value as? [String: AnyObject] else{
                return
            }
            user = UersInfo(dict: dict)
        }else if key == "retweeted_status"{
            guard let dict = value as? [String: AnyObject] else {
                return
            }
            retweeted_status = WeiboStatus(dict: dict)
         
            
        }else if key == "pic_urls"{
            guard let pics = value as? [[String: AnyObject]] else{
                return
            }
            //遍历转换类型
            var temp = [PictureUrls]()
            for dict in pics {
                temp.append(PictureUrls(dict: dict))
            }
            pic_urls = temp
            
            
        }else{
            super.setValue(value, forKey: key)
        }
    }
    
    
}
